package com.jmpt.fangbohui.adapter;

import java.util.List;

import com.jmpt.fangbohui.R;
import com.jmpt.fangbohui.bean.BrokerPersonNetSotreEsHouseBean1.Retval;
import com.jmpt.fangbohui.ui.OldHouseDetailActivity;
import com.jmpt.fangbohui.utils.DebugLog;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

public class BrokerPersonNetSotreEsHouse1ListAdapter extends BaseAdapter{

	private Context mContext;
	private List<Retval> mData;
	public BrokerPersonNetSotreEsHouse1ListAdapter(Context mContext,List<Retval> mData){
		this.mContext = mContext;
		this.mData = mData;
	}
	@Override
	public int getCount() {
		return mData.size();
	}

	@Override
	public Object getItem(int position) {
		return mData.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		ViewHolder  holder = null;
		if(convertView == null){
			holder = new ViewHolder();
			convertView = View.inflate(mContext, R.layout.item_broker_person_net_store_eshouse_1, null);
			holder.H_Title = (TextView)convertView.findViewById(R.id.H_Title);
			holder.H_Hall = (TextView)convertView.findViewById(R.id.H_Hall);
			holder.H_Room = (TextView)convertView.findViewById(R.id.H_Room);
			holder.H_MJ = (TextView)convertView.findViewById(R.id.H_MJ);
			holder.H_SaleOrRent = (TextView)convertView.findViewById(R.id.H_SaleOrRent);
			holder.H_SalePrice = (TextView)convertView.findViewById(R.id.H_SalePrice);
			holder.price_type = (TextView)convertView.findViewById(R.id.price_type);
			holder.H_SendInfoName = (TextView)convertView.findViewById(R.id.H_SendInfoName);
			holder.H_SendInfoTel = (TextView)convertView.findViewById(R.id.H_SendInfoTel);
			holder.H_DZ = (TextView)convertView.findViewById(R.id.H_DZ);
			holder.ll_item_broker_person_net_store_1 = (LinearLayout) convertView.findViewById(R.id.ll_item_broker_person_net_store_1);
			convertView.setTag(holder);
		}else{
			holder = (ViewHolder) convertView.getTag();
		}
		holder.H_DZ.setText(mData.get(position).H_DZ);
		holder.H_Title.setText(mData.get(position).H_Title);
		holder.H_Hall.setText(mData.get(position).H_Hall);
		holder.H_Room.setText(mData.get(position).H_Room);
		holder.H_MJ.setText(mData.get(position).H_MJ);
		holder.H_SaleOrRent.setText(mData.get(position).H_SaleOrRent);
		holder.H_SalePrice.setText(mData.get(position).H_SalePrice);
		holder.price_type.setText(mData.get(position).price_type);
		holder.H_SendInfoName.setText(mData.get(position).H_SendInfoName);
		holder.H_SendInfoTel.setText(mData.get(position).H_SendInfoTel);
		holder.ll_item_broker_person_net_store_1.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(mContext,OldHouseDetailActivity.class);
				intent.putExtra("HOUSE_ID", mData.get(position).HouseID);
				intent.putExtra("HOUSE_TITLE", mData.get(position).H_Title);
				DebugLog.i(mData.get(position).HouseID+"");
				mContext.startActivity(intent);
			}
		});
		return convertView;
	}
	public class ViewHolder{
		public LinearLayout ll_item_broker_person_net_store_1;
		public TextView H_Title;
		public TextView H_Hall;
		public TextView H_Room;
		public TextView H_MJ;
		public TextView H_SaleOrRent;
		public TextView H_SalePrice;
		public TextView price_type;
		public TextView H_SendInfoName;
		public TextView H_SendInfoTel;
		public TextView H_DZ;
		
	}
}
